//
//  BaseModel.m
//  yilutongxing
//
//  Created by 赵继申 on 17/3/11.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import "BaseModel.h"
#import "YYText.h"
@implementation BaseModel
-(float)textHeight{
    if (_textHeight==0) {
        YYTextView *tv = [[YYTextView alloc]initWithFrame:CGRectMake(8, 0, SCREEN_WIDTH-2*8, 0)];
        tv.font = [UIFont systemFontOfSize:15];
        //计算文本高度
        
        tv.text = self.content;
        _textHeight += tv.textLayout.textBoundingSize.height;
    }
    return _textHeight;
}

-(float)imagesHeight{
    float size = ([UIScreen mainScreen].bounds.size.width-2*8-10)/3;
    if (_imagesHeight==0) {
        if (self.imagePaths.count==1) {
            _imagesHeight = 2*size;
        }else{
            NSInteger line = self.imagePaths.count%3==0?self.imagePaths.count/3:self.imagePaths.count/3+1;
            
            
            _imagesHeight = line *size + (line-1)*8;
            
            
        }
    }
    
    return _imagesHeight;
}


-(NSArray *)imagePaths{
    _imagePaths=[_imageurls componentsSeparatedByString:@","];
    return _imagePaths;
}


- (void)setValue:(id)value forKey:(NSString *)key{
    
    //手动处理description
    if ([key isEqualToString: @"id"]) {
        
        _ID = value;
    }else{
        
        //调用父类方法，保证其他属性正常加载
        [super setValue:value forKey:key];
    }
}
@end
